<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>


    <script>

        function User() { };
        User.prototype.sayHello = function () {
            console.log('hello');
        };
        let u1 = new User();
        let u2 = new User();

        console.log(u1.sayHello === u2.sayHello);
        //每个对象都有__proto__,指向它的构造函数的prototype
        console.log(u1.__proto__ === User.prototype);
        console.log(u1.__proto__.__proto__ === Object.prototype);
        console.log(User.prototype.__proto__ === Object.prototype);
        console.log(User.prototype.__proto__.__proto__);//null
        console.log(u2.__proto__.constructor);
        console.log(User.prototype.constructor);
        //在查找成员时，如果自己本身没有，就会顺着原型链网上找
        console.log(u2.constructor);


        let arr = new Array();
        arr.push(10);
        console.log(arr);
        console.log(Array.prototype);
        console.log(arr.__proto__ === Array.prototype);
        console.log(arr.constructor);
        console.log(Array.prototype.constructor);
        console.log(arr.__proto__.__proto__.constructor);
        console.log(arr.__proto__.__proto__.__proto__);
        console.log(Function.__proto__);
    </script>

</body>

</html>